package dao

import (
	"fmt"
	"github.com/gogf/gf/database/gdb"
	"github.com/gogf/gf/frame/g"
)

type t_op_log_set_day struct {
}

var T_op_log_set_day = t_op_log_set_day{}

func (a *t_op_log_set_day) GetList(where ...string) (list gdb.List, err error) {
	db := g.DB(g.Cfg().GetString("custom.db_name"))
	model := db.Model("t_op_log_set_day")
	if len(where) == 0 {
	} else {
		model = model.Where(where[0])
	}
	res, err := model.All()
	return res.List(), err
}

func (a *t_op_log_set_day) Save(data interface{}) (isOk bool, err error) {
	db := g.DB(g.Cfg().GetString("custom.db_name"))
	_, err = db.Model("t_op_log_set_day").Data(data).Save()
	if err != nil {
		return false, err
	} else {
		return true, nil
	}
}

func (a *t_op_log_set_day) Delete(id string) (isOk bool, err error) {
	db := g.DB(g.Cfg().GetString("custom.db_name"))
	_, err = db.Model("t_op_log_set_day").Delete(fmt.Sprintf("id=%s", id))
	if err != nil {
		return false, err
	} else {
		return true, nil
	}
}
